#ifndef GTL_TIME_HEADER_GUARD
#define GTL_TIME_HEADER_GUARD

#include "gtlCompilerSpecific.h"

namespace GTL
{
  namespace Time
  {

    /// Code shamelessly stolen from the HL2/AlienSwarm SDK
    inline uint64_t GetDesktopCPURealTimeStamp()
    {
      uint64_t time = 0;
    #ifdef GTL_COMPILER_GCC
      uint64_t* pSample = (uint64_t *)&time;
      __asm__ __volatile__ (  
        "rdtsc\n\t"
        "movl %%eax,  (%0)\n\t"
        "movl %%edx, 4(%0)\n\t"
        : /* no output regs */
      : "D" (pSample)
        : "%eax", "%edx" );
    #elif defined( GTL_COMPILER_VISUAL_STUDIO )
      uint64_t* pSample = (uint64_t *)&time;
      __asm
      {
        mov		ecx, pSample
        rdtsc
        mov		[ecx], eax
        mov		[ecx+4], edx
      }
    #elif defined( GTL_COMPILER_POSIX_COMPLIANT )
      uint64_t* pSample = (uint64_t *)&time;
        __asm__ __volatile__ (  
        "rdtsc\n\t"
        "movl %%eax,  (%0)\n\t"
        "movl %%edx, 4(%0)\n\t"
        : /* no output regs */
        : "D" (pSample)
        : "%eax", "%edx" );
    #endif

      return time;
    }
    
  }
}

#endif